package cn.player.download;

import android.content.Context;

import java.io.File;

import cn.player.download.file.DiskUsage;
import cn.player.download.file.Files;
import cn.player.download.file.TotalCountLruDiskUsage;


/**
 * Created by xingliao_zgl on 16/7/8.
 */
public class DownloadConfiguration {


    private static final int DEFAULT_MAX_CACHE_FILE_COUNT = 100;


    private int maxCacheFileCount;
    private String cacheFilePath;
    private DiskUsage lruDiskCache;


    public DownloadConfiguration(Context context) {
        this.maxCacheFileCount = DEFAULT_MAX_CACHE_FILE_COUNT;
        this.lruDiskCache = new TotalCountLruDiskUsage(maxCacheFileCount);
        this.cacheFilePath = Files.getCacheDirectory(context);
    }


    public File generateCacheFile(String name) {
        return new File(cacheFilePath, name);
    }

    public int getMaxCacheFileCount() {
        return maxCacheFileCount;
    }

    public void setMaxCacheFileCount(int maxCacheFileCount) {
        this.maxCacheFileCount = maxCacheFileCount;
    }

    public String getCacheFilePath() {
        return cacheFilePath;
    }

    public void setCacheFilePath(String cacheFilePath) {
        this.cacheFilePath = cacheFilePath;
    }

    public DiskUsage getLruDiskCache() {
        return lruDiskCache;
    }

    public void setLruDiskCache(DiskUsage lruDiskCache) {
        this.lruDiskCache = lruDiskCache;
    }
}
